package com.ht.project.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ht.common.entity.PageInfo;
import com.ht.project.dao.PromanageDao;
import com.ht.project.service.PromanageService;
import com.ht.right.entity.ProamanageHeadModel;
import com.ht.right.service.CommonFacadeService;

public class PromanageServiceImpl  implements PromanageService{
	private PromanageDao promanageDao;
	private CommonFacadeService<ProamanageHeadModel> commonFacadeService;
	
	public PromanageDao getPromanageDao() {
		return promanageDao;
	}

	public void setPromanageDao(PromanageDao promanageDao) {
		this.promanageDao = promanageDao;
	}

	@Override
	public void addPromanage(ProamanageHeadModel proamanageHeadModel,
			String sameLevelNodeId) {
		promanageDao.save(proamanageHeadModel);
		
	}

	@Override
	public ProamanageHeadModel findProamanageHeadModelById(String uuId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ProamanageHeadModel> findAllProList() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ProamanageHeadModel> findChildProList(
			ProamanageHeadModel proamanageHeadModel) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Map<String, String>> findAllProsJson() {
		return getList(promanageDao.findAllProList());
	}

	@Override
	public List<Map<String, String>> findChildProJson(
			ProamanageHeadModel proamanageHeadModel) {
		return getList(promanageDao.findChildProList(proamanageHeadModel));
	}

	@Override
	public void updatePro(ProamanageHeadModel proamanageHeadModel,
			String sameLevelNodeId) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void deletePro(ProamanageHeadModel proamanageHeadModel) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void deleteProById(String deptId) {
		// TODO Auto-generated method stub
		
	}
	
	private List<Map<String,String>> getList(List<ProamanageHeadModel> proList){
		List<Map<String,String>> list = new ArrayList<Map<String,String>>();
		for(ProamanageHeadModel promanege : proList){
			Map<String,String> map = new HashMap<String,String>();
			map.put("id", promanege.getUuid());
			map.put("projectNo",promanege.getProjectNo());
			/*map.put("pid", dept.getDeptPid());
			map.put("type", "dept");*/
			list.add(map);
		}
		return list;
	}

	@Override
	public Map<String, Object> findListByPromanageIdForPage(ProamanageHeadModel proamanageHeadModel, PageInfo pageInfo) {
		
		return promanageDao.findListByProamanageIdForPage(proamanageHeadModel, pageInfo);
	}

	public CommonFacadeService<ProamanageHeadModel> getCommonFacadeService() {
		return commonFacadeService;
	}

	public void setCommonFacadeService(
			CommonFacadeService<ProamanageHeadModel> commonFacadeService) {
		this.commonFacadeService = commonFacadeService;
	}

	@Override
	public void save(ProamanageHeadModel proamanageHeadModel, String rightId) {
		promanageDao.save(proamanageHeadModel);
	}
	
}
